package bean;

public class Book {

    private int bookId;
    private String bookName;

    public Book() {
        System.out.println("---------------------book");
    }

    public int getBookId() {
        return bookId;
    }

    public void setBookId(int bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookId=" + bookId +
                ", bookName='" + bookName + '\'' +
                '}';
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    //初始化方法：在创建当前类时调用的方法，进行资源准备
    public void init(){
        System.out.println("-----------init");
        this.bookId = 1;
        this.bookName = "初始值";
    }

    //销毁方法：Spring容器销毁对象时调用的方法，进行资源回收
    //多例模式在GC回收时销毁；
    //单例模式在Spring容器关闭时销毁。
    public void destroy(){
        System.out.println("-----------destroy");
    }
}
